package com.rentong.wx.cust.controller;

import com.rentong.common.R;
import com.rentong.wx.cust.domain.CustFapiaoApplyEntity;
import com.rentong.wx.cust.dto.CustFapiaoApplyEntityDto;
import com.rentong.wx.cust.service.CustFapiaoApplyService;
import com.rentong.wx.utils.WxApiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zhangle
 * @email 459343178@qq.com
 * @date 2024-12-24 14:42:33
 */
@RestController
public class CustFapiaoApplyController {

    @Autowired
    private CustFapiaoApplyService custFapiaoApplyService;


    /*
     * 205、开票，新增开票申请（下单没成交的话，需要看下，有没有之前已经提交了开票申请的，需要删掉的）
     *
     * */
    @RequestMapping("/custFapiaoApply/insertFapiaoApply")
    public R insertFapiaoApply(CustFapiaoApplyEntityDto custFapiaoApplyEntityDto, HttpServletRequest request) throws Exception {
        custFapiaoApplyEntityDto.setCustId(WxApiUtil.getCurrentCustId(request));

        int i = custFapiaoApplyService.insertFapiaoApply(custFapiaoApplyEntityDto);

        if (i > 0) {
            return R.success("开票申请成功");
        } else {
            return R.error("开票申请失败");
        }
    }

    /*
     * 206、展示开票记录列表
     *
     * */
    @RequestMapping("/custFapiaoApply/getFapiaoApplyList")
    public R getFapiaoApplyList(CustFapiaoApplyEntityDto custFapiaoApplyEntityDto, HttpServletRequest request) throws Exception {
        custFapiaoApplyEntityDto.setCustId(WxApiUtil.getCurrentCustId(request));
        return R.success(custFapiaoApplyService.getFapiaoApplyList(custFapiaoApplyEntityDto));
    }


}
